<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta charset="utf-8">
	<title>超市进销存管理系统</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="icon" href="/resources/favicon.ico">
	<link rel="stylesheet" href="/resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="/resources/css/index.css" media="all" />
</head>
<body class="main_body">
	<div class="layui-layout layui-layout-admin ">
		<!-- 顶部 -->
		<div class="layui-header header ">
				<a href="#" class="logo"><img src="resources/images/logo.png" width="160px"></a>
			<div class="layui-main mag0">
				<!-- 显示/隐藏菜单 -->
				<a href="javascript:;" class="seraph hideMenu icon-caidan"></a>
			    <!-- 顶部右侧菜单 -->
				<ul class="layui-nav top_menu ">
					<li class="layui-nav-item" >
						<blockquote >
							<div id="nowTime"></div>
						</blockquote>
					</li>
					<li class="layui-nav-item" id="userInfo">
						<a href="javascript:;"><img src="/resources/images/face.jpg" class="layui-nav-img userAvatar" width="35" height="35"><cite class="adminName" th:text="${session.username.uname}">1111</cite></a>
						<dl class="layui-nav-child">
							<dd><a href="javascript:;" class="updatepwd"><i class="seraph icon-xiugai" data-icon="icon-xiugai"></i><cite>修改密码</cite></a></dd>
							<dd><a  href="javascript:;" class="signOut"><i class="seraph icon-tuichu"></i><cite>退出登陆</cite></a></dd>
						</dl>
					</li>

				</ul>
			</div>
		</div>
		<!-- 左侧导航 -->
		<div class="layui-side layui-bg-black">
			<div class="navBar layui-side-scroll" id="navBar">
				<ul class="layui-nav layui-nav-tree">
					<li class="layui-nav-item layui-this">
						<a href="javascript:;" data-url="/toDes"><i class="layui-icon" data-icon=""></i><cite>后台首页</cite></a>
					</li>
				</ul>
			</div>
		</div>
		<!-- 右侧内容 -->
		<div class="layui-body layui-form">
			<div class="layui-tab mag0" lay-filter="bodyTab" id="top_tabs_box">
				<ul class="layui-tab-title top_tab" id="top_tabs">
					<li class="layui-this" lay-id=""><i class="layui-icon">&#xe68e;</i> <cite>后台首页</cite></li>
				</ul>
				<ul class="layui-nav closeBox">
				  <li class="layui-nav-item">
				    <a href="javascript:;"><i class="layui-icon caozuo">&#xe643;</i> 页面操作</a>
				    <dl class="layui-nav-child">
					  <dd><a href="javascript:;" class="refresh refreshThis"><i class="layui-icon">&#x1002;</i> 刷新当前</a></dd>
				      <dd><a href="javascript:;" class="closePageOther"><i class="seraph icon-prohibit"></i> 关闭其他</a></dd>
				      <dd><a href="javascript:;" class="closePageAll"><i class="seraph icon-guanbi"></i> 关闭全部</a></dd>
				    </dl>
				  </li>
				</ul>
				<div class="layui-tab-content clildFrame">
					<div class="layui-tab-item layui-show">
						<iframe src="/toDes"></iframe>
					</div>
				</div>
			</div>
		</div>
		<!-- 底部 -->
		<div class="layui-footer footer">
			<p><span>copyright @2021 </span></p>
		</div>
	</div>

	<!-- 移动导航 -->
	<div class="site-tree-mobile"><i class="layui-icon">&#xe602;</i></div>
	<div class="site-mobile-shade"></div>

	<!--修改密码弹出框-->
	<div  style="display: none;padding: 5px" id="UpdateDiv">
		<form class="layui-form layui-row changePwd" id="dataFrm" lay-filter="dataFrm">
			<div  class="layui-form-item layui-row layui-col-xs12">
				<div class="layui-form-item">
					<label class="layui-form-label">新密码</label>
					<div class="layui-input-block">
						<input type="password" name="newPassWord1" placeholder="请输入新密码" lay-verify="required|newPwd"  class="layui-input pwd">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">确认密码</label>
					<div class="layui-input-block">
						<input type="password" name="newPassWord2" placeholder="请确认密码" lay-verify="required|confirmPwd" class="layui-input pwd">
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit="" lay-filter="changePwd">立即修改</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</div>
		</form>
	</div>


	<script type="text/javascript" src="/resources/layui/layui.js"></script>
	<script type="text/javascript" src="/resources/js/cache.js"></script>

	<script type="text/javascript" src="/resources/layui/layui.js"></script>

	<script>

		//在js中获取session数据 themleaf行内写法
		var uname='[[${session.username.uname}]]';
		//获取系统时间
		var newDate = '';
		getLangDate();
		//值小于10时，在前面补0
		function dateFilter(date){
			if(date < 10){return "0"+date;}
			return date;
		}
		function getLangDate(){
			var dateObj = new Date(); //表示当前系统时间的Date对象
			var year = dateObj.getFullYear(); //当前系统时间的完整年份值
			var month = dateObj.getMonth()+1; //当前系统时间的月份值
			var date = dateObj.getDate(); //当前系统时间的月份中的日
			var day = dateObj.getDay(); //当前系统时间中的星期值
			var weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
			var week = weeks[day]; //根据星期值，从数组中获取对应的星期字符串
			var hour = dateObj.getHours(); //当前系统时间的小时值
			var minute = dateObj.getMinutes(); //当前系统时间的分钟值
			var second = dateObj.getSeconds(); //当前系统时间的秒钟值
			var timeValue = "" +((hour >= 12) ? (hour >= 18) ? "晚上" : "下午" : "上午" ); //当前时间属于上午、晚上还是下午
			newDate = dateFilter(year)+"年"+dateFilter(month)+"月"+dateFilter(date)+"日 "+" "+dateFilter(hour)+":"+dateFilter(minute)+":"+dateFilter(second);
			document.getElementById("nowTime").innerHTML = ""+uname+"，"+timeValue+"好！欢迎使用超市进销存管理系统。当前时间为："+newDate+" "+week+" ";
			setTimeout("getLangDate()",1000);
		}

		layui.use(['form','element','layer','jquery'],function(){
			var form = layui.form,
					layer = parent.layer === undefined ? layui.layer : top.layer,
					element = layui.element;
			$ = layui.jquery;
			//上次登录时间
			$(".loginTime").html(newDate.split("日")[0]+"日</br>"+newDate.split("日")[1]);
			//icon动画
			$(".panel a").hover(function(){
				$(this).find(".layui-anim").addClass("layui-anim-scaleSpring");
			},function(){
				$(this).find(".layui-anim").removeClass("layui-anim-scaleSpring");
			})
			$(".panel a").click(function(){
				parent.addTab($(this));
			})


		})

	</script>
	<script>
		var $,tab,dataStr,layer;
		layui.config({
			base : "/resources/js/"
		}).extend({
			"bodyTab" : "bodyTab"
		})

		layui.use(['bodyTab','form','element','layer','jquery',],function(){
			var layer=layui.layer,
			$=layui.jquery;
			var form = layui.form, element = layui.element;
			$ = layui.$;
			layer = parent.layer === undefined ? layui.layer : top.layer;
			tab = layui.bodyTab({
				openTabNum : "50",  //最大可打开窗口数量
				url : "/menu/loadIndexLeftMenuTree" //获取菜单json地址
			});

			var mainIndex;//弹出层的索引下标
			var url;//提交路径

			// 修改
			function openUpdateCategoryWindow(data) {
				mainIndex = layer.open({
					type:1,
					title:"修改密码",
					area:["400px","300px"],
					content:$("#UpdateDiv"),//内容窗口
					success:function () {
						url="/user/updateUserPassWord";
					}
				});
			}

			//修改密码
			$(".updatepwd").click(function (obj) {
				var data =obj.data;
				openUpdateCategoryWindow(data);

			});


			//退出登陆
			$(".signOut").click(function () {
				layer.confirm('确定要退出吗?', {icon: 3, title: '提示'}, function (index) {
					layer.close(index);//关闭提示框
					window.parent.location.href ="/logout";
				});
			});

			//监听添加和修改窗口的提交事件
			form.on("submit(changePwd)", function (data) {
				//表格数据重新加载
				console.log(data);

				var newPassWord1 = data.field.newPassWord1;
				var newPassWord2 =data.field.newPassWord2;
				$.post(url,{"newPassWord1":newPassWord1,"newPassWord2":newPassWord2},function (result) {
					//判断是否成功
					if (result.status){
						//弹出是否成功消息
						layer.msg(result.message);
						window.parent.location.href ="/logout";
					}
					else {
						layer.msg(result.message);
					}

					//关闭窗口
					layer.close(mainIndex)
				},"json");
				return false; //关闭跳转页面
			});

			//通过顶部菜单获取左侧二三级菜单
			function getData(json){
				$.getJSON(tab.tabConfig.url,function(result){
					dataStr = result.data;
					//重新渲染左侧菜单
					tab.render();
				})
			}
			//页面加载时判断左侧菜单是否显示
			//通过顶部菜单获取左侧菜单
			$(".topLevelMenus li,.mobileTopLevelMenus dd").click(function(){
				if($(this).parents(".mobileTopLevelMenus").length != "0"){
					$(".topLevelMenus li").eq($(this).index()).addClass("layui-this").siblings().removeClass("layui-this");
				}else{
					$(".mobileTopLevelMenus dd").eq($(this).index()).addClass("layui-this").siblings().removeClass("layui-this");
				}
				$(".layui-layout-admin").removeClass("showMenu");
				$("body").addClass("site-mobile");
				getData($(this).data("menu"));
				//渲染顶部窗口
				tab.tabMove();
			})

			//隐藏左侧导航
			$(".hideMenu").click(function(){
				if($(".topLevelMenus li.layui-this a").data("url")){
					layer.msg("此栏目状态下左侧菜单不可展开");  //主要为了避免左侧显示的内容与顶部菜单不匹配
					return false;
				}
				$(".layui-layout-admin").toggleClass("showMenu");
				//渲染顶部窗口
				tab.tabMove();
			})

			//通过顶部菜单获取左侧二三级菜单   注：此处只做演示之用，实际开发中通过接口传参的方式获取导航数据
			getData("contentManagement");

			//手机设备的简单适配
			$('.site-tree-mobile').on('click', function(){
				$('body').addClass('site-mobile');
			});
			$('.site-mobile-shade').on('click', function(){
				$('body').removeClass('site-mobile');
			});

			// 添加新窗口
			$("body").on("click",".layui-nav .layui-nav-item a:not('.mobileTopLevelMenus .layui-nav-item a')",function(){
				//如果不存在子级
				if($(this).siblings().length == 0){
					addTab($(this));
					$('body').removeClass('site-mobile');  //移动端点击菜单关闭菜单层
				}
				$(this).parent("li").siblings().removeClass("layui-nav-itemed");
			})

			//刷新后还原打开的窗口
			if(cacheStr == "true") {
				if (window.sessionStorage.getItem("menu") != null) {
					menu = JSON.parse(window.sessionStorage.getItem("menu"));
					curmenu = window.sessionStorage.getItem("curmenu");
					var openTitle = '';
					for (var i = 0; i < menu.length; i++) {
						openTitle = '';
						if (menu[i].icon) {
							if (menu[i].icon.split("-")[0] == 'icon') {
								openTitle += '<i class="seraph ' + menu[i].icon + '"></i>';
							} else {
								openTitle += '<i class="layui-icon">' + menu[i].icon + '</i>';
							}
						}
						openTitle += '<cite>' + menu[i].title + '</cite>';
						openTitle += '<i class="layui-icon layui-unselect layui-tab-close" data-id="' + menu[i].layId + '">&#x1006;</i>';
						element.tabAdd("bodyTab", {
							title: openTitle,
							content: "<iframe src='" + menu[i].href + "' data-id='" + menu[i].layId + "'></frame>",
							id: menu[i].layId
						})
						//定位到刷新前的窗口
						if (curmenu != "undefined") {
							if (curmenu == '' || curmenu == "null") {  //定位到后台首页
								element.tabChange("bodyTab", '');
							} else if (JSON.parse(curmenu).title == menu[i].title) {  //定位到刷新前的页面
								element.tabChange("bodyTab", menu[i].layId);
							}
						} else {
							element.tabChange("bodyTab", menu[menu.length - 1].layId);
						}
					}
					//渲染顶部窗口
					tab.tabMove();
				}
			}else{
				window.sessionStorage.removeItem("menu");
				window.sessionStorage.removeItem("curmenu");
			}
		});



		//打开新窗口
		function addTab(_this){
			tab.tabAdd(_this);
		}

	</script>
</body>
</html>